package model;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/9/1.
 */
public class SpecialClassifyModel {
    /**
     * result : 1
     * data : [{"attr":[{"typeName":"不限","typeId":"","typePressName":"不限"},{"typeName":"男 ","typePressName":"男","typeId":1},{"typeName":"女 ","typePressName":"女","typeId":2}],"name":"性别","type":"3"},{"attr":[{"typeName":"不限","typeId":"","typePressName":"不限"},{"typeId":"35","typePressName":"35","typeName":"35"},{"typeId":"36","typePressName":"36","typeName":"36"},{"typeId":"37","typePressName":"37","typeName":"37"},{"typeId":"38","typePressName":"38","typeName":"38"},{"typeId":"39","typePressName":"39","typeName":"39"},{"typeId":"40","typePressName":"40","typeName":"40"},{"typeId":"41","typePressName":"41","typeName":"41"},{"typeId":"42","typePressName":"42","typeName":"42"},{"typeId":"43","typePressName":"43","typeName":"43"},{"typeId":"44","typePressName":"44","typeName":"44"}],"name":"尺寸","type":"1"}]
     */

    private int result;
    /**
     * attr : [{"typeName":"不限","typeId":"","typePressName":"不限"},{"typeName":"男 ","typePressName":"男","typeId":1},{"typeName":"女 ","typePressName":"女","typeId":2}]
     * name : 性别
     * type : 3
     */

    private List<DataBean> data;

    public static SpecialClassifyModel objectFromData(String str) {

        return new Gson().fromJson(str, SpecialClassifyModel.class);
    }

    public static SpecialClassifyModel objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new Gson().fromJson(jsonObject.getString(str), SpecialClassifyModel.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public static List<SpecialClassifyModel> arraySpecialClassifyModelFromData(String str) {

        Type listType = new TypeToken<ArrayList<SpecialClassifyModel>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public static List<SpecialClassifyModel> arraySpecialClassifyModelFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);
            Type listType = new TypeToken<ArrayList<SpecialClassifyModel>>() {
            }.getType();

            return new Gson().fromJson(jsonObject.getString(str), listType);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new ArrayList();


    }

    public int getResult() {
        return result;
    }

    public void setResult(int result) {
        this.result = result;
    }

    public List<DataBean> getData() {
        return data;
    }

    public void setData(List<DataBean> data) {
        this.data = data;
    }

    public static class DataBean {
        private String name;
        private String type;
        /**
         * typeName : 不限
         * typeId :
         * typePressName : 不限
         */

        private List<AttrBean> attr;

        public static DataBean objectFromData(String str) {

            return new Gson().fromJson(str, DataBean.class);
        }

        public static DataBean objectFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);

                return new Gson().fromJson(jsonObject.getString(str), DataBean.class);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }

        public static List<DataBean> arrayDataBeanFromData(String str) {

            Type listType = new TypeToken<ArrayList<DataBean>>() {
            }.getType();

            return new Gson().fromJson(str, listType);
        }

        public static List<DataBean> arrayDataBeanFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);
                Type listType = new TypeToken<ArrayList<DataBean>>() {
                }.getType();

                return new Gson().fromJson(jsonObject.getString(str), listType);

            } catch (JSONException e) {
                e.printStackTrace();
            }

            return new ArrayList();


        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public List<AttrBean> getAttr() {
            return attr;
        }

        public void setAttr(List<AttrBean> attr) {
            this.attr = attr;
        }

        public static class AttrBean {
            private String typeName;
            private String typeId;
            private String typePressName;

            public static AttrBean objectFromData(String str) {

                return new Gson().fromJson(str, AttrBean.class);
            }

            public static AttrBean objectFromData(String str, String key) {

                try {
                    JSONObject jsonObject = new JSONObject(str);

                    return new Gson().fromJson(jsonObject.getString(str), AttrBean.class);
                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return null;
            }

            public static List<AttrBean> arrayAttrBeanFromData(String str) {

                Type listType = new TypeToken<ArrayList<AttrBean>>() {
                }.getType();

                return new Gson().fromJson(str, listType);
            }

            public static List<AttrBean> arrayAttrBeanFromData(String str, String key) {

                try {
                    JSONObject jsonObject = new JSONObject(str);
                    Type listType = new TypeToken<ArrayList<AttrBean>>() {
                    }.getType();

                    return new Gson().fromJson(jsonObject.getString(str), listType);

                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return new ArrayList();


            }

            public String getTypeName() {
                return typeName;
            }

            public void setTypeName(String typeName) {
                this.typeName = typeName;
            }

            public String getTypeId() {
                return typeId;
            }

            public void setTypeId(String typeId) {
                this.typeId = typeId;
            }

            public String getTypePressName() {
                return typePressName;
            }

            public void setTypePressName(String typePressName) {
                this.typePressName = typePressName;
            }
        }
    }
}
